package util;

import java.util.Random;

public class CodeGenerator {

    public static String getCode() {
        Random random = new Random();
        char[] code = new char[4];
        for (int i = 0; i < 3; i++) {
            int r1 = random.nextInt(2);
            int r2 = random.nextInt(26);
            if (r1 == 0) {
                code[i] = (char) (r2 + 'a');
            } else {
                code[i] = (char) (r2 + 'A');
            }
        }
        int r3 = random.nextInt(10);
        code[3] = (char) (r3 + '0');
        for (int i = 0; i < 4; i++) {
            int r5 = random.nextInt(4);
            char temp = code[i];
            code[i] = code[r5];
            code[r5] = temp;
        }
        return new String(code);
    }
}
